//
//  InsteonOnCommand.m
//  Shion
//
//  Created by Chris Karr on 12/17/07.
//  Copyright 2007-2008 Audacious Software. All rights reserved.
//

#import "InsteonOnCommand.h"

@implementation InsteonOnCommand

- (InsteonOnCommand *) init
{
	if (self = [super init])
		level = 0xFF;
		
	return self;
}

- (NSData *) commandData
{
	unsigned char bytes[] = {0x02,0x40, 0x01,0xA4, 0x00,0x06, 0xFD,0x88, 0x00,0x00,0x00, 0x0F,0x11,level};
	
	// unsigned char bytes[] = {0x02,0x40, 0x01,0xA4, 0x00,0x06, 0xFD,0x88, 0x00,0x00,0x00, 0x0F,0x2E,0x99};
	NSMutableData * data = [NSMutableData dataWithBytes:bytes length:14];
	
	if (address != nil)
		[data replaceBytesInRange:NSMakeRange (8, [address length]) withBytes:[address bytes]];


	return data;
}

- (void) setLevel:(NSInteger) newLevel
{
	level = (char) newLevel;
}

@end
